#include<iostream>
#include<vector>
#include<string>
#include<string.h>
#include <unordered_set>
#include <algorithm>
using namespace std;


//2
//5 6 8 11 9
//10 12 9


int main()
{
	vector<int> nums;
	unordered_set<int> seen;
	int repeat = -1;
	int missing = -1;
	int N = 0;
	cin >> N;
	for (int i = 0; i < N; i++);
	{
		int num = 0;
		cin >> num;
		while (true)
		{
			if (cin.peek() == '\n') break;
			nums.push_back(num);
		}
		
	}
	sort(nums.begin(), nums.end());

	for (int i = 0 ; i < nums.size() -1 ;i++)
	{
		if (nums[i] == nums[i + 1])
		{
			repeat = nums[i];
		}
		else if (nums[i] != nums[i] + 1)
		{
			missing = nums[i];
		}
	}

	cout << missing << " " << repeat << endl;
	return 0;
}